<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新增</title>
    <link href="//unpkg.com/layui@2.7.6/dist/css/layui.css" rel="stylesheet">
</head>
<body>
<div style="margin-top: 25px">
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">用户昵称：</label>
            <div class="layui-input-inline">
                <input type="text" name="userName" id="userName" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">登录账号：</label>
            <div class="layui-input-inline">
                <input type="text" name="loginName" id="loginName" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码：</label>
            <div class="layui-input-inline">
                <input type="text" name="password" id="password" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
                <input type="radio" name="sex" value="0" title="男" checked="">
                <input type="radio" name="sex" value="1" title="女">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮箱：</label>
            <div class="layui-input-inline">
                <input type="text" name="email" id="email" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">电话：</label>
            <div class="layui-input-inline">
                <input type="text" name="phonenumber" id="phonenumber" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户类型：</label>
            <div class="layui-input-inline">
                <select name="userType" id="userType" lay-filter="aihao">
                    <option value="00">系统用户</option>
                    <option value="01">注册用户</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">部门：</label>
            <div class="layui-input-inline">
                <select name="deptId" id="deptId" lay-filter="aihao">
                    <option value="103">研发部门</option>
                    <option value="104">市场部门</option>
                    <option value="105">测试部门</option>
                    <option value="106">财务部门</option>
                    <option value="107">运维部门</option>
                    <option value="108">市场部门</option>
                    <option value="109">财务部门</option>
                </select>
            </div>
        </div>

        <div class="layui-block">
            <div class="layui-input-block">
                <button type="submit" id="sub" class="layui-btn" lay-filter="user-add" lay-submit="" >添加</button>
            </div>
        </div>
    </form>
</div>
<script src="${pageContext.request.contextPath}/statics/layui/layui/layui.js"></script>
<script src="${pageContext.request.contextPath}/Pear-Admin-Layui/component/pear/pear.js"></script>
<script>

    layui.use(['form', 'jquery'], function () {
        let form = layui.form;
        let $ = layui.jquery;

        form.on('submit(user-add)', function (data) {
            $.post('add', data.field, function (result) {
                console.log(result)
                if (result) {
                    //关闭当前页
                    parent.layer.close(parent.layer.getFrameIndex(window.name));
                    parent.layer.msg('新增成功', {icon: 1, time: 2000});
                } else {
                    layer.msg(result.msg, {
                        icon: 2,
                        time: 1000
                    });
                }
            })
            return false;
        });
    })

</script>

</body>
</html>
